package com.yl.ylnews.base.imp;

import android.app.Activity;
import android.graphics.Color;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;

import com.yl.ylnews.base.BaseMenuDetailPager;
import com.yl.ylnews.base.BaseViewPager;
import com.yl.ylnews.base.imp.menu.NewsMenuDetailPager;
import com.yl.ylnews.base.imp.menu.WheatherMenuDetailPager;
import com.yl.ylnews.global.GlobalConstants;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/10/17 0017.
 */

public class NewsPager extends BaseViewPager {
    private static final String TAG = "NewsPager";
    private List<BaseMenuDetailPager> mPagers;

    public NewsPager(Activity mActivity) {
        super(mActivity);
    }

    @Override
    public void initData() {
        tv_tittle.setText("新闻");
        TextView textView = new TextView(mActivity);
        textView.setText("新闻");
        textView.setGravity(Gravity.CENTER);
        textView.setTextColor(Color.RED);
        fl_content.addView(textView);

        mPagers = new ArrayList<>();
        mPagers.add(new NewsMenuDetailPager(mActivity));
        mPagers.add(new WheatherMenuDetailPager(mActivity));

        setCurrentMenuDetailPager(0);

    }




    public void setCurrentMenuDetailPager(int position) {
        BaseMenuDetailPager pager = mPagers.get(position);
        View view = pager.initView();
        fl_content.removeAllViews();
        fl_content.addView(view);
        //修改标题
        tv_tittle.setText(GlobalConstants.MENU_ARR[position]);
        //初始化页面数据
        pager.initData();
    }
}
